﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

public partial class Admin_ModifyUsername : DLL.MyAdminPage
{
	private DLL.User.Component clsUserComp;

	protected void Page_Load(object sender, EventArgs e)
	{
		if (!IsPostBack)
		{
			ShowOldUsername();
		}
	}

	protected override void OnInit(EventArgs e)
	{
		clsUserComp = new DLL.User.Component(Page);

		base.OnInit(e);

		LBtnModify.Click += new EventHandler(LBtnModify_Click);
	}

	/// <summary>
	/// 修改用户名按钮
	/// </summary>
	/// <param name="sender"></param>
	/// <param name="e"></param>
	void LBtnModify_Click(object sender, EventArgs e)
	{
		if (clsUserComp.ModifyUsername(nUserID, TbNewUsername.Text.Trim()))
		{
			TonyNet4V1.ShowMessageAlert.ShowMessage(Page, "用户名修改成功！");
			ShowOldUsername();
			TbNewUsername.Text = "";
		}
	}

	/// <summary>
	/// 显示老用户名
	/// </summary>
	private void ShowOldUsername()
	{
		TbOldUsername.Text = clsUserComp.GetOne(nUserID).Username;
	}
}